﻿using DLL.NET50.DB.MS.AdviceAndDrug.ORM.Repository;
using DLL.NET60.DB.MS.Entity.DTO;
using System;
using System.Collections.Generic;
using System.Text;

namespace DLL.NET50.DB.MS.AdviceAndDrug.ORM.Service
{
    public interface IAdviceAndDicDrugsService
    {
        //提前加载数据
        void LoadData();

        /// <summary>
        /// 根据瓶贴号编码，获取医嘱和药品
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns></returns>
        CMS_AdviceAndDrug GetAdviceAndDrug(string barCode);

        /// <summary>
        /// 根据瓶贴号，获取医嘱数量
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns></returns>
        int GetAdviceCount(string barCode);

        /// <summary>
        /// 获取总的医嘱数量
        /// </summary>
        /// <returns></returns>
        int GetAllAdviceCount();

        List<DTO_adi_dic_drug> GetDrugByCode(string drugCode);

        CDrugCodes GetAllDrugCode(string barCode);

        CDrugCodes GetLoacalNotExistDrugCodes(string barCode);

        List<string> GetAllDrugCodeByBarCode(string barCode);

        List<string> GetNotExistDrugByBarCode(string barCode);
    }

    public class CAdviceAndDicDrugsService : IAdviceAndDicDrugsService
    {
        public IAdviceAndDicDrugsRepository _repository;

        public CAdviceAndDicDrugsService(IAdviceAndDicDrugsRepository repository) //: base(unitOfWork, repository)
        {
            //_unitOfWork = unitOfWork;
            this._repository = repository;
        }

        public void LoadData()
        {
            _repository.LoadData();
        }

        /// <summary>
        /// 根据瓶贴号编码，获取医嘱和药品
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns></returns>
        public CMS_AdviceAndDrug GetAdviceAndDrug(string barCode)
        {
            return _repository.GetAdviceAndDrug(barCode);
        }

        /// <summary>
        /// 根据瓶贴号，获取医嘱数量
        /// </summary>
        /// <param name="barCode"></param>
        /// <returns></returns>
        public int GetAdviceCount(string barCode)
        {
            return _repository.GetAdviceCount(barCode);
        }

        /// <summary>
        /// 获取总的医嘱数量
        /// </summary>
        /// <returns></returns>
        public int GetAllAdviceCount()
        {
            return _repository.GetAllAdviceCount();
        }

        public List<DTO_adi_dic_drug> GetDrugByCode(string drugCode)
        {
            return _repository.GetDrugByCode(drugCode);
        }

        public CDrugCodes GetAllDrugCode(string barCode)
        {
            return _repository.GetAllDrugCode(barCode);
        }

        public CDrugCodes GetLoacalNotExistDrugCodes(string barCode)
        {
            return _repository.GetLoacalNotExistDrugCodes(barCode);
        }

        public List<string> GetNotExistDrugByBarCode(string barCode)
        {
            return _repository.GetNotExistDrugByBarCode(barCode);
        }

        public List<string> GetAllDrugCodeByBarCode(string barCode)
        {
            return _repository.GetAllDrugCodeByBarCode(barCode);
        }
    }
}